package cn.ducis.macaw.core.staticflies.file;

import cn.ducis.macaw.util.basic.PathUtil;

/**
 * @author Yellow
 *
 */
@Deprecated
public class SubPathUtil {
	private static final char separator = '_';

	/**
	 * 将小文件的路径名除去文件名部分以下划线代替路径分隔符作为块文件名称的一部分
	 * 
	 * @param path
	 * @return eg: "D:\\dir1/subdir/image.jpg" ->"D:_dir1_subdir_"
	 */
	public static String pathToBlockName(String path) {
		path = PathUtil.getDirString(path);
		String blockName = path.replace('/', separator);
		return blockName;
	}

	/**
	 * 将由路径转换成块文件名称的字符串转换回文件路径
	 * 
	 * @param blockName
	 * @return eg: "D:_dir1_subdir_" -> "D:/dir1/subdir/"
	 */
	public static String BlockNameToPart(String blockName) {
		return blockName.replace(separator, '/');
	}
}
